package com.example.sxt_practise.访问权限控制符;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 * author gaofeng
 * date 2021年08月13日 20:30
 *
 * @author 高枫
 */
public class Test {

    public static final List<Integer> userIds = Arrays.asList(1, 2);

    Map<Integer, String> map = new HashMap<>();

    public static void main(String[] args) {

//        String url = "www.baidu.com" ;
//        String json = JSON.toJSONString(url) ;
//
//        String yMonths=LocalDate.now().minusMonths(1).toString();
//        System.out.println(yMonths);


        Calendar c = Calendar.getInstance();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        c.setTime(new Date());
        c.add(Calendar.MONTH, -1);
        Date m = c.getTime();
        String mon = format.format(m);
        System.out.println("过去一个月：" + mon);

        System.out.println(getMonthDays(2021, 8));


        /*Student  student = new Student() ;
        student.setAge(1);*/
//        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
//        System.out.println();
   /*     Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(simpleDateFormat.format(new Date()));
        System.out.println(LocalDate.now().toString());*/


       /*SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
       Calendar calendar = Calendar.getInstance();
       String date1 = "2021-09-06" ;
       Date old = dateFormat.parse(date1) ;
       calendar.setTime(old) ;
       Long oTIme = calendar.getTimeInMillis() ;

        String date2 = "2021-09-06" ;
        Date now = dateFormat.parse(date2) ;
        calendar.setTime(now) ;
        Long nTIme = calendar.getTimeInMillis() ;

        System.out.println((nTIme - oTIme)/(3600F * 1000 * 24));*/


    }

    // year 年份（四位数）
    // month 月份（从1开始）
    /**
     * 计算一个月有多少天
     * @author gaofeng
     * @Date  2021/9/30 11:03
     * @param year
     * @param month
     * @return int
     */
    public static int getMonthDays(int year, int month) {
        if (month == 2) {
            if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
                return 29;
            } else {
                return 28;
            }
        } else if (month == 4 || month == 6 || month == 9 || month == 11) {
            return 30;
        } else {
            return 31;
        }
    }

}
